<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/5/11
 * Time: 11:08
 */

namespace app\stationpc\controller;

use app\model\StationMemberInfo as ModelStationMemberInfo;


class MemberInfo extends Member
{
    public function _initialize()
    {
        parent::_initialize();
    }

    /**
     * 判断手机号是否存在
     * uri:/stationpc/phoneNo.judge
     */
    public function phoneNoJudge(){
        $phoneNo = $this->_getContentParams('phoneNo');
        $data = ModelStationMemberInfo::getInstance()->toFind("mobile=$phoneNo");
        if ($data>0){
            $judge=1;
        }else{
            $judge=0;
        }
        _returnData($judge);
    }

    /**
     * 站点人员添加
     * uri:/stationpc/stationMemberInfo.add
     */
    public function stationMemberInfoAdd(){
        $memberNumber = $this->_getContentParams('memberNumber');
        $memberName = $this->_getContentParams('memberName');
        $mobile = $this->_getContentParams('mobile');
        $memberAddress = $this->_getContentParams('memberAddress');
        $str_pwd_key = $this->_getRandomString(8);
        $password = passwordEncryption('123456', $str_pwd_key);
        $arr = [
            'station_id'=>$this->station_id,
            'member_number'=>$memberNumber,
            'member_name'=>$memberName,
            'mobile'=>$mobile,
            'member_address'=>$memberAddress,
            'pwd_key'=>$str_pwd_key,
            'password'=>$password
        ];
        $data = ModelStationMemberInfo::getInstance()->toAdd($arr);
        _returnData($data);
    }
}